package se.mbaeumer.jarvisualizer.gui;

import java.io.IOException;

import se.mbaeumer.jarvisualizer.main.JarVisualization;
import javafx.geometry.Orientation;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.scene.paint.Color;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

public class VisualizationInfoStage extends Stage {

	private Group root = new Group();
	private Scene scene;
	private FlowPane flowGeneral;
	
	private Label lblFileName = new Label("Filename: ");
	private Label lblTotalNodes = new Label("Nodes: ");
	private Label lblPackages = new Label("Packages: ");
	private Label lblClasses = new Label("Classes: ");
	private Label lblInterfaces = new Label("Interfaces: ");
	private Label lblEnums = new Label("Enums: ");
	
	private JarVisualization jarVisualization;
	public VisualizationInfoStage(JarVisualization jarVisualization){
		this.jarVisualization = jarVisualization;
		this.scene = new Scene(this.root, 200, 200, Color.LIGHTGRAY);
		this.setScene(this.scene);
		
		this.setTitle("Visualization Info");
		
		this.initModality(Modality.APPLICATION_MODAL);
		this.initStyle(StageStyle.UTILITY);
		
		this.createGeneralFlowPane();
	}
	
	private void createGeneralFlowPane(){
		this.flowGeneral = new FlowPane(Orientation.VERTICAL);
		this.flowGeneral.setVgap(10);
		this.root.getChildren().add(this.flowGeneral);
		
		try {
			this.lblFileName.setText(this.lblFileName.getText() + this.jarVisualization.getJarFile().getCanonicalPath());
		} catch (IOException e) {
			e.printStackTrace();
		}
		this.lblTotalNodes.setText(this.lblTotalNodes.getText() + this.jarVisualization.getGraph().getTotalNumberOfNodes());
		this.lblPackages.setText(this.lblPackages.getText() + this.jarVisualization.getGraph().getNumberOfPackageNodes());
		this.lblClasses.setText(this.lblClasses.getText() + this.jarVisualization.getGraph().getNumberOfClassNodes());
		this.lblInterfaces.setText(this.lblInterfaces.getText() + this.jarVisualization.getGraph().getNumberOfInterfaceNodes());
		this.lblEnums.setText(this.lblEnums.getText() + this.jarVisualization.getGraph().getNumberOfEnumNodes());
		
		this.flowGeneral.getChildren().addAll(this.lblFileName, this.lblTotalNodes, this.lblPackages, this.lblClasses, this.lblInterfaces, this.lblEnums);
	}
}
